// 模拟任务的使用
#include <string>

enum return_value
{
    great,
    divide_zero,
    mod_zero,
    undefine_op
};

const std::string operaters = "+-*/%";

class task
{
public:
    task(int data1 = 0, int data2 = 0, char op = ' ')
        : _data1(data1), _data2(data2), _op(op), _result(0), _r(great) {}

    void run()
    {
        switch (_op)
        {
        case '+':
            _result = _data1 + _data2;
            break;
        case '-':
            _result = _data1 - _data2;
            break;
        case '*':
            _result = _data1 * _data2;
            break;
        case '/':
            if(!_data2) _r = divide_zero, _result = -1;
            else _result = _data1 / _data2;
            break;
        case '%':
            if(!_data2) _r = mod_zero, _result = -1;
            else _result = _data1 % _data2;
            break;
        }
    }

    std::string get_task() { return std::to_string(_data1) + _op + std::to_string(_data2) + "=?"; }

    std::string get_result() 
    {
        std::string s = std::to_string(_data1) + _op + std::to_string(_data2);
        s += '=' + std::to_string(_result) + '[' + "code:" + std::to_string(_r) + ']';
        return s;
    }
private:
    int _data1;
    int _data2;
    char _op;
    int _result;
    return_value _r;
};